#
# @lc app=leetcode.cn id=9 lang=python
#
# [9] 回文数
#

# @lc code=start
class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        # 转换为字符串，然后用双指针的方法处理
        if x == 0:
            return True
        elif x < 0:
            return False
        else:
            x_string = str(x)
            i, j = 0, len(x_string)-1
            while i < j:
                if x_string[i] != x_string[j]:
                    return False
                i = i + 1
                j = j - 1
            return True


class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        # 将整形数字x按位拆分后进行双指针遍历
        if x == 0:
            return True
        elif x < 0:
            return False
        else:
            x_split = list()
            while x != 0:
                x_split.append(x % 10)
                x = int(x / 10)
            print(x_split)
            i, j = 0, len(x_split)-1
            while i < j:
                if x_split[i] != x_split[j]:
                    return False
                i += 1
                j -= 1
            return True
# @lc code=end


if __name__ == "__main__":
    solution = Solution()
    solution.isPalindrome(12321)
